package com.zcl.javaClassAndObject.collection.typeUnknown8_2_1;

import java.util.Stack;

/**
 * @Description:
 * @author: zcl
 * @date: 2021/12/13  11:58
 */
public class Stacks {
    static String[] months = {
            "January", "February", "March", "April",
            "May", "June", "July", "August", "September",
            "October", "November", "December"};

    public static void main(String[] args) {
        Stack stk = new Stack();
        for (int i = 0; i < months.length; i++) {
            stk.push(months[i] + " ");
            System.out.println("stk = " + stk);
        }
        // Treating a stack as a Vector:
        stk.addElement("the last line!");
        System.out.println("element 5 = " + stk.elementAt(5));
        System.out.println("popping elements:");
        while (!stk.empty()) {
            System.out.println(stk.pop());
        }
    }
}
/**
 * stk = [January ]
 * stk = [January , February ]
 * stk = [January , February , March ]
 * stk = [January , February , March , April ]
 * stk = [January , February , March , April , May ]
 * stk = [January , February , March , April , May , June ]
 * stk = [January , February , March , April , May , June , July ]
 * stk = [January , February , March , April , May , June , July , August ]
 * stk = [January , February , March , April , May , June , July , August , September ]
 * stk = [January , February , March , April , May , June , July , August , September , October ]
 * stk = [January , February , March , April , May , June , July , August , September , October , November ]
 * stk = [January , February , March , April , May , June , July , August , September , October , November , December ]
 * element 5 = June
 * popping elements:
 * the last line!
 * December
 * November
 * October
 * September
 * August
 * July
 * June
 * May
 * April
 * March
 * February
 * January
 * */